import request from '@/utils/request'

const base_api = '/admin/system/sysRole'
// 获取角色列表
export const GetSysRoleListByPage =(current , limit , queryDto) => {
    return request({
        url: `${base_api}/findByPage/${current}/${limit}`,
        method: 'POST',
        data: queryDto
    })
}

//角色添加
export const SaveSysRole = (sysRole) => {
    return request({
        url: `${base_api}/saveSysRole`,
        method: 'post',
        data: sysRole
    })
}

//角色修改
export const UpdateSysRole = (sysRole) => {
    return request({
        url: `${base_api}/updateSysRole`,
        method: 'put',
        data: sysRole
    })  
}

// 删除角色
export const DeleteSysRoleById = (roleId) => {
    return request({
        url: `${base_api}/delete/${roleId}`,
        method: 'delete'
    })
}

// 查询所有的角色数据
export const GetAllRoleList = (userId) => {
    return request({
        url: `${base_api}/findAllRoles/${userId}`,
        method: 'get'
    })
}

// 查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = (roleId) => {
    return request({
        url: "/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/"+ roleId,
        method: 'get'
    })
}

// 根据角色分配菜单请求方法
export const DoAssignMenuIdToSysRole = (assignMenuDto) => {
    return request({
        url: "/admin/system/sysRoleMenu/doAssign",
        method: 'post',
        data: assignMenuDto
    })
}